
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.support.ui.WebDriverWait;

import org.openqa.selenium.chrome.ChromeDriver;


public class Selenium2Example {
    public static void main(String[] args) {
        // Sätt sökväg till chromedriver   s
        System.setProperty("webdriver.chrome.driver", "C:/chromedriver.exe");

        //Skapa ny instans av webdriver
        WebDriver driver = new ChromeDriver();

        // And now use this to visit Google
        driver.get("https://lms.oru.se/");

        // Find the text input element by its name
        WebElement studentButton = driver.findElement(By.xpath("//*[@id=\"visibleDiv\"]/ul/li[2]/input"));

        studentButton.click();

        //Vänta 1 sek
        new WebDriverWait(driver, 1000);

        // Find the text input element by its name
        WebElement username = driver.findElement(By.xpath("//*[@id=\"username\"]"));
        WebElement password = driver.findElement(By.xpath("//*[@id=\"password\"]"));
        WebElement login = driver.findElement(By.xpath("//*[@id=\"fm1\"]/div[1]/div[4]/div/input[1]"));

        username.sendKeys("olameh081");
        password.sendKeys("u5nodr7w3!");
        login.click();

        //nästa sida inloggad
        WebElement globalnav = driver.findElement(By.xpath("//*[@id=\"global-nav-link\"]"));
        globalnav.click();

        driver.get("https://lms.oru.se/webapps/portal/frameset.jsp?tab_tab_group_id=_20_1&url=%2Fwebapps%2Fblackboard%2Fexecute%2Flauncher%3Ftype%3DCourse%26id%3D_5927_1%26url%3D");

        driver.get("https://lms.oru.se/webapps/blackboard/content/launchLink.jsp?course_id=_5927_1&tool_id=_303_1&tool_type=TOOL&mode=view&mode=reset");

        WebElement skapamsg = driver.findElement(By.xpath("//*[@id=\"nav\"]/li[1]/a"));
        skapamsg.click();

        WebElement subject = driver.findElement(By.xpath("//*[@id=\"subject_t\"]"));

        subject.sendKeys("Hej väderkvarnen, det är FILIP din beundrare");

        new WebDriverWait(driver, 5000);


        //Close the browser
        //driver.quit();
    }
}
